'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:AttendanceAttendanceDepsCtrl
 * @description
 * # AttendanceAttendanceDepsCtrl
 * Controller of the jgappApp
 */
angular.module('jgappApp')
  .controller('AttendanceAttendanceDepsCtrl', function (DataService,Util, openApi, localStorageService, $routeParams) {
    var vm = this;
    var attDetail = localStorageService.get("attDetail")||{};
    this.peoplelist = [];
    var userArr = []
    var init = function () {
      var param = {};
      param.acId = $routeParams.id;
      DataService.getData(openApi.attSelectdepartment, param).then(function (data) {
        vm.deplist = data
        console.log(data)
      })
    }
    this.confirm = function () {
      userArr = vm.deplist.filter(function (item, index) {
        return item.selected;
      })
      attDetail.department = userArr.map(function (item, index) {
        return item.value
      })
      attDetail.departments = userArr.map(function (item, index) {
        return item.text
      }).toString();
      localStorageService.set("attDetail", attDetail);
      Util.goBack();
    }
    init()
  });
